home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / boosters.arc / XWORDS.PAS < prev   
Pascal/Delphi Source File  |  1985-11-14  |  1KB  |  49 lines

  1. {$IBoDecl}
  2. {$IStrip}
  3. {$ICenter}
  4. {$IRword}
  5. {$IWord}
  6. {$IWords}
  7. {$IWordInd}
  8. {$ISpace}
  9.  
  10. var
  11.    Ts : AnyString;
  12.    j  : Integer;
  13.  
  14. BEGIN
  15.    ClrScr;
  16.    Write( Center ( 'Type a message for analysis. Q to quit.',80,' '));
  17.    Write( Center ( '''n , string'' replaces word n of previous message'+
  18.                   ' with ''string''',80,' ') );
  19.    window (1,3,80,25);
  20.    repeat
  21.       readln( S );
  22.       S := space(S);
  23.       if Length(S) > 0 then
  24.       begin
  25.          val ( word(S,1), i, ecode );
  26.          if (ecode = 0) and (word(S,2) = ',') then
  27.          begin
  28.             j := WordInd (S, 3);
  29.             Ts := rword ( Ts , i, copy ( S, j, Length(S)-j+1) );
  30.             Writeln ( Ts );
  31.          end
  32.          else
  33.          begin
  34.             Ts := S;
  35.             Writeln ( S );
  36.             i := 1 + Random(Words(Ts));
  37.          end;
  38.          GotoXY( WordInd(Ts,i), WhereY );
  39.          writeln( #004 );
  40.          Writeln( 'There are ',words(Ts),' words in your message.');
  41.          Writeln('There are ',length(word(Ts,i)),' characters in word ',i);
  42.       end { Length > 0 };
  43.    until (S = 'Q') or (S = 'q');
  44.    window (1,1,80,25);
  45.  
  46. END.
  47.  
  48.  
  49.